package cifra.protocolo.bluehand;

import java.io.Serializable;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import com.google.ads.AdView;

import data.LivroData;

public class Livros extends Activity implements Interface {
	private TextView pergunta;
	private CheckBox protocoloAlien, protocoloZumbi;
	private Button botao;
	private Typeface font;
	private LivroData livro;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		livro = new LivroData();

		setFullScreen(Livros.this);
		setContentView(R.layout.livros);

		String fonte = "SVBasicManual.ttf";
		Typeface font = Typeface.createFromAsset(getAssets(), "fonts/" + fonte);

		pergunta = (TextView) findViewById(R.id.pergunta);
		protocoloAlien = (CheckBox) findViewById(R.id.CheckBox01);
		protocoloZumbi = (CheckBox) findViewById(R.id.CheckBox02);
		botao = (Button) findViewById(R.id.botao);

		pergunta.setTypeface(font);
		protocoloAlien.setTypeface(font);
		protocoloZumbi.setTypeface(font);
		botao.setTypeface(font);

		AdView adView = (AdView) findViewById(R.id.adView);
		adView.setEnabled(false);

		avancar();

	}

	@Override
	public void efeito() {
		overridePendingTransition(R.anim.push_left_in, R.anim.push_up_out);
	}

	@Override
	protected void onPause() {
		super.onPause();

	}

	@Override
	public void avancar() {
		botao.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				preparaDados();
				enviaDados("livros", livro);
				efeito();
			}
		});
	}

	public void send() {

	}

	@Override
	public void enviaDados(String chave, Serializable objeto) {
		// TODO Auto-generated method stub
		Intent intent = new Intent(getApplicationContext(), Regiao.class);
		Bundle bundle = new Bundle();
		bundle.putSerializable(chave, objeto);
		intent.putExtras(bundle);
		startActivityForResult(intent, 1);
	}

	@Override
	public void preparaDados() {
		if (protocoloAlien.isChecked()) {
			livro.setLivroAlienigena(true);
		} else {
			livro.setLivroAlienigena(false);
		}

		if (protocoloZumbi.isChecked()) {
			livro.setLivroZumbi(true);
		} else {
			livro.setLivroZumbi(false);
		}
	}

	@Override
	public void setFullScreen(Context currContext) {
		((Activity) currContext).requestWindowFeature(Window.FEATURE_NO_TITLE);
		((Activity) currContext).getWindow().setFlags(
				WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}
}
